package lion.spider.anno;

import java.lang.annotation.Annotation;

import lion.dev.lang.MapJ;
import lion.framework.core.anno.AnnoProcessor;
import lion.framework.core.anno.AnnotationProcessorManager;
import lion.framework.core.anno.IAnnotationProcessor;
import lion.framework.core.bean.BeanFactory;
import lion.spider.IParseHandler;

/**
 * @author lion
 * @email hl_0074@sina.com
 * @date 2016年5月9日
 */
@AnnoProcessor(ParseHandler.class)
public class ParseHandlerAnnoProcessor implements IAnnotationProcessor {

	@Override
	public void processe(MapJ ctx, Annotation anno) throws Exception {

		Class<?> clazz = ctx.getE(AnnotationProcessorManager.ANNO_CONTEXT_CLASS);
		if (clazz.isAssignableFrom(IParseHandler.class)) { return; }

		ParseHandler parseAnno = (ParseHandler) anno;
		ParseHandlerManager.regist(parseAnno.value(), (IParseHandler) BeanFactory.create(clazz));
	}
}
